package com.bridge.service.impl;

import com.bridge.dao.BrandDao;
import com.bridge.entity.Brand;
import com.bridge.service.BrandService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bridge
 * @Date 2022/06/16/21:14
 */

@Service
public class BrandServiceImpl implements BrandService {
    private static final Logger log = LoggerFactory.getLogger(BrandServiceImpl.class);

    @Autowired
    private BrandDao brandDao;

    public List<Brand> findBrands(String name) {
        long t1 = System.currentTimeMillis();
        List<Brand> list = brandDao.findBrands(name);
        long t2 = System.currentTimeMillis();
        log.info("findBrands->time->{}", (t2 - t1));
        return list;
    }

    @Override
    public List<Brand> queryList() {
        return brandDao.queryList();
    }

    public int deleteById(Integer id) {
        //1.参数校验
        //2.执行删除业务
        int rows = brandDao.deleteById(id);
        //3.校验结果并返回
        return rows;
    }

    @Override
    public int saveBrand(Brand brand){
        int rows=brandDao.insertBrand(brand);
        return rows;
    }


    @Override
    public Brand findById(Integer id) {
        //.....
        return brandDao.findById(id);
    }

    @Override
    public int updateBrand(Brand brand) {
        return brandDao.updateBrand(brand);
    }


}


